package com.weseal.controller;

import com.weseal.controller.base.BaseController;
import com.weseal.exception.UserException;
import com.weseal.form.UserInfoForm;
import com.weseal.query.UserInfoQuery;
import com.weseal.response.CommonResult;
import com.weseal.service.UserInfoService;
import com.weseal.vo.UserInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.UUID;

/**
 * @author weseal
 * @title
 * @description
 * @usage
 * @copyright Copyright 2014  rrmj Corporation. All rights reserved.
 * @company 上海众多美网络科技有限公司
 * @create 2017/9/6
 */
@Controller
@RequestMapping("/user")
public class UserInfoController extends BaseController {


	@Autowired
	private UserInfoService userInfoService;
	
	
	@RequestMapping("/token")
	@ResponseBody
	public CommonResult<UserInfoVo> token(UserInfoQuery query) {
		CommonResult<UserInfoVo> userInfoVoResponseResult = CommonResult.initSuccess();
		UserInfoVo userInfoVo = new UserInfoVo();
		userInfoVo.setToken(UUID.randomUUID().toString());
		userInfoVoResponseResult.setData(userInfoVo);
		return userInfoVoResponseResult;
	}

	@RequestMapping("/thirdParty/login")
	@ResponseBody
	public CommonResult<UserInfoVo> thirdPartyLogin(UserInfoQuery query) {
		CommonResult<UserInfoVo> userInfoVoResponseResult = CommonResult.errorInstant(UserException.USER_INFO_EXCEPTION);
		if(System.currentTimeMillis() % 3 == 1)
			userInfoVoResponseResult = CommonResult.initSuccess();
		UserInfoVo userInfoVo = new UserInfoVo();
		userInfoVo.setId(1L);
		userInfoVo.setToken(UUID.randomUUID().toString());
		userInfoVoResponseResult.setData(userInfoVo);
		return userInfoVoResponseResult;
	}
	
	@RequestMapping("/thirdParty/register")
	@ResponseBody
	public CommonResult<UserInfoVo> thirdPartyRegister(UserInfoForm form) {
		CommonResult<UserInfoVo> userInfoVoResponseResult = CommonResult.initSuccess();
		UserInfoVo userInfoVo = new UserInfoVo();
		userInfoVoResponseResult.setData(userInfoVo);
		return userInfoVoResponseResult;
	}
	
	

}
